 // 根据数据绘制转孔信息
const BatchTurnHole = function (params) {
    viewer.entities.removeAll()
    //地质开挖不能有深度测试，有深度测试会被遮盖
    viewer.scene.globe.depthTestAgainstTerrain = false;
    viewer.scene.fxaa = false
    viewer.scene.postProcessStages.fxaa.enabled = false;
    var supportsImageRenderingPixelated = viewer.cesiumWidget._supportsImageRenderingPixelated;
    if (supportsImageRenderingPixelated) {
        var vtxf_dpr = window.devicePixelRatio;
        while (vtxf_dpr >= 2.0) { vtxf_dpr /= 2.0; }
        viewer.resolutionScale = vtxf_dpr;
    }


    var turnDataSource = null;
    turnDataSource = new Cesium.CustomDataSource('turnEntities');

    var drawSingleCylinder = function (data) {
        turnDataSource.entities.add({
            position: Cesium.Cartesian3.fromDegrees(data.lon, data.lat, data.height),
            cylinder: {
                length: data.length,
                topRadius: 10,
                bottomRadius: 10,
                material: data.color || Cesium.Color.BLUE
            }
            // id: options.id,
            // polylineVolume: {
            //     positions: positionsOut,
            //     clampToGround: true,
            //     shape: this.computeCircle(this.circleRadius + this.circleDifference * 2),
            //     // material: Cesium.Color.RED.withAlpha(0.6),
            //     material: new Cesium.ImageMaterialProperty({
            //         image: "../../../asset/materialImg/gongye.jpg", // require("./img/gongye.jpg"), //图片
            //         repeat: new Cesium.Cartesian2(10, 2), //s,t方向重复次数
            //     }), //图片材质
            //     // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(-3000.0, 2000.0),
            // },
        });
    }
    if (params && params.data && params.data.length) {
        for (let i = 0; i < params.data.length; i++) {
            const layerLit = params.data[i];
            if (layerLit && layerLit.layers.length) {
                for (let j = 0; j < layerLit.layers.length; j++) {
                    const geo = layerLit.layers[j];
                    drawSingleCylinder(geo)
                }
            }

        }
    }
    viewer.dataSources.add(turnDataSource);
    viewer.flyTo(turnDataSource);

}

export default BatchTurnHole